<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Vue3 中 ref 访问dom元素</title>
</head>

<body>
    <script src="https://unpkg.com/vue@3/dist/vue.global.js"></script>
    <div id="Application">
        <div ref="hello">简简单单的晚饭</div>
    </div>
    <script>
        const App = Vue.createApp({
            setup() {

                const hello = Vue.ref(null);
                console.log("第一次获取：", hello.value);
                Vue.onMounted(() => {
                    //dom加载后再获取
                    console.log("onMound后获取：", hello.value); // <div>简简单单的晚饭</div>
                    console.log("onMound后获取：", hello.value.textContent); // 简简单单的晚饭

                });
                return {
                    hello
                };
            },
        });
        App.mount("#Application");
    </script>
</body>

</html>